<?php
define("__OA_ENV", "DEV");
require_once dirname(__FILE__)  . '/../libs/PaymentInterface.php';

require_once 'PHPUnit/Framework.php';
require_once 'Log.php';

class PaymentInterfaceTest extends PHPUnit_Framework_TestCase
{
    private $_logger;
    private $_interface;
    
    protected function setUp()
    {
        $logger = Log::factory('console', '', '', array(), PEAR_LOG_INFO);
        $this->_logger = $logger;
        $this->_interface = new PaymentInterface(PaymentInterface::APP_ENV_TEST);
    }
    
    protected function tearDown()
    {
        
    }
    
    public function testOpen()
    {
        $this->markTestSkipped();
        $arr = array(
        	'appId'=>110111500,
        	'spId'=>1000135,
          	'DepositConfigEx'=>array( 'businessType'=>PaymentInterface::BUSINESS_TYPE_COMMON, 'appStatus'=>PaymentInterface::PAYMENT_STATUS_TEST),
          );
        $result = $this->_interface->open( $arr);
        if($this->_interface->getErrNo()) {
            print_r($this->_interface->getErrMsg()."||".$this->_interface->getErrNo());
        }
        $this->assertTrue($result !== false);
        return $result;
    }
    
    public function testGet()
    {
        $this->markTestSkipped();
        $arr = array(
            'appId'=>110111700,
        	'spId'=>1000135,
          );
        $result = $this->_interface->get( $arr);
        if($this->_interface->getErrNo()) {
            print_r($this->_interface->getErrMsg()."||".$this->_interface->getErrNo());
        }
        print_r($result);
        $this->assertTrue(is_array($result));
        return $result;
    }
    
    public function testUpdate()
    {
//        $this->markTestSkipped();
        $arr = array(
        	'appId'=>110111500,
        	'spId'=>1000135,
          	'DepositConfigEx'=>array( 'businessType'=>PaymentInterface::BUSINESS_TYPE_COMMON, 'appStatus'=>PaymentInterface::PAYMENT_STATUS_ONLINE),
//            'appStatus'=>array('status'=>2)  
        );
        $result = $this->_interface->update( $arr, PaymentInterface::APP_ENV_PRODUCTION);
        if($this->_interface->getErrNo()) {
            print_r($this->_interface->getErrMsg()."||".$this->_interface->getErrNo());
        }
        $this->assertTrue($result !== false);
        return $result;
    }
    
    public function testSync()
    {
        $this->markTestSkipped();
        $arr = array(
        	'appId'=>110111500,
        	'spId'=>1000135,
          	'testAccounts'=>array( 
                'mobfan','mobfan',
             ),
             'syncArea'=>1
          );
        $result = $this->_interface->sync( $arr, PaymentInterface::APP_ENV_PRODUCTION);
        if($this->_interface->getErrNo()) {
            print_r($this->_interface->getErrMsg()."||".$this->_interface->getErrNo());
        }
        $this->assertTrue($result !== false);
        return $result;
    }
    
	public function testClose()
    {
        $this->markTestSkipped();
        $arr = array(
            'appId'=>110111500,
        	'spId'=>1000135,
          );
        $result = $this->_interface->close( $arr);
        if($this->_interface->getErrNo()) {
            print_r($this->_interface->getErrMsg()."||".$this->_interface->getErrNo());
        }
        $this->assertTrue($result !==false);
        return $result;
    }
    
}
